using System;
using System.Collections.Generic;
using System.Text;

namespace MacomberMap.Common.Events
{
    /// <summary>
    /// This class represents a member not found error
    /// </summary>
    public class MM_Event_MemberNotFound: MM_Event
    {
        #region Variable declarations
        /// <summary>
        /// The name of the member
        /// </summary>
        public string MemberName;

        /// <summary>
        /// The item in which the member could not be located
        /// </summary>
        public Object Target;
        #endregion

        #region Initialization
        /// <summary>
        /// Initiailzie a new member not found error
        /// </summary>
        /// <param name="MemberName">The name of the member</param>
        /// <param name="Target">The target for the memeber</param>
        public MM_Event_MemberNotFound(String MemberName, Object Target)
        {
            this.MemberName = MemberName;
            this.Target = Target;
        }
        #endregion

        /// <summary>
        /// Compare two member not found errors
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override int CompareTo(Object obj)
        {
            return MemberName.CompareTo((obj as MM_Event_MemberNotFound).MemberName);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="OutMenu"></param>
        public override void AddMenuItems(System.Windows.Forms.ContextMenuStrip OutMenu)
        {
            //throw new Exception("The method or operation is not implemented.");
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override System.Windows.Forms.ListViewItem BuildListViewItem()
        {
            System.Windows.Forms.ListViewItem NewItem = new System.Windows.Forms.ListViewItem(Target.ToString() + "." + MemberName);
            NewItem.SubItems.Add(this.EventState.ToString());
            NewItem.SubItems.Add(TimeText);
            NewItem.ImageIndex = EventType.Index;
            return NewItem;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="OutParent"></param>
        public override void DisplayDetails(System.Windows.Forms.Control OutParent)
        {
            System.Windows.Forms.TreeView tvOut = new System.Windows.Forms.TreeView();
            tvOut.Dock = System.Windows.Forms.DockStyle.Fill;
            this.AddNodeItem("Member", this.MemberName, tvOut.Nodes);
            this.AddNodeItem("Target", this.Target, tvOut.Nodes);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="lvItem"></param>
        public override void UpdateListViewItem(System.Windows.Forms.ListViewItem lvItem)
        {
            lvItem.SubItems[0].Text = Target.ToString() + "." + MemberName;
            lvItem.SubItems[1].Text = this.EventState.ToString();
            lvItem.SubItems[2].Text = TimeText;
        }
    }
}
